package com.td.framework.common;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;
import com.td.framework.webmanager.login.UserInfo;
import com.td.framework.webmanager.page.Page;
import com.td.framework.webmanager.page.PageService;

public class AbstractAction extends ActionSupport implements Action {

	/**
	 * 基础的action类
	 */
	private static final long serialVersionUID = -8946916640769177563L;
	private HttpServletRequest request;  //取得请求
    private HttpServletResponse response;  // 取得相应
    private HttpSession httpsession;  //取得session
    protected String whereClause;
    //分页
    protected int pageSize; // 每页显示行数
    protected int currentPage; //取得页面上的当前的页
    protected String pageMethod; // 取得将执行怎样的分页
    protected PageService pageService; //分页接口
    protected int toPagNum;//跳到第几页
    protected Page page; //分页实体
    //页面公用部分
    protected long[] zids; //主键id
     //spring注入的service
    private IBaseService baseService;
    public String result; //结果
    private int editState;//增加1、修改2、查看3
    
    public AbstractAction() {
		super();
		// TODO Auto-generated constructor stub
	}    
    /**
     * 得到用户信息
     * @return
     */
    public UserInfo getUserInfo(){
    	return (UserInfo) this.getHttpsession().getAttribute("userInfo");
    }
    /**
     * 操作结果反馈
     * @return
     */
    public void handleMessage(String key,String value){
      this.getRequest().setAttribute(key,value);	
    }
	//private UserInfo userInfo;
	public HttpServletRequest getRequest() {
		request = ServletActionContext.getRequest();
		return request;
	}
	public void setRequest(HttpServletRequest request) {
		this.request = request;
	}
	public HttpServletResponse getResponse() {
		response =ServletActionContext.getResponse();
		return response;
	}
	public void setResponse(HttpServletResponse response) {
		this.response = response;
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public int getCurrentPage() {
		return currentPage;
	}
	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}
	public String getPageMethod() {
		return pageMethod;
	}
	public void setPageMethod(String pageMethod) {
		this.pageMethod = pageMethod;
	}

	public PageService getPageService() {
		return pageService;
	}
	public void setPageService(PageService pageService) {
		this.pageService = pageService;
	}
	public Page getPage() {
		return page;
	}
	public void setPage(Page page) {
		this.page = page;
	}
	public HttpSession getHttpsession() {
		httpsession =getRequest().getSession();
		return httpsession;
	}
	public void setHttpsession(HttpSession httpsession) {
		this.httpsession = httpsession;
	}
	public int getToPagNum() {
		return toPagNum;
	}
	public void setToPagNum(int toPagNum) {
		this.toPagNum = toPagNum;
	}
	public IBaseService getBaseService() {
		return baseService;
	}
	public void setBaseService(IBaseService baseService) {
		this.baseService = baseService;
	}
	public String getWhereClause() {
		return whereClause;
	}
	public void setWhereClause(String whereClause) {
		this.whereClause = whereClause;
	}
	public long[] getZids() {
		return zids;
	}
	public void setZids(long[] zids) {
		this.zids = zids;
	}
	public int getEditState() {
		return editState;
	}
	/**
	 * 1表示添加、2表示修改、3表示查看
	 * @param editState
	 */
	public void setEditState(int editState) {
		this.editState = editState;
	}
	
    
}
